import 'package:json_annotation/json_annotation.dart';

part 'recipe_search_list_api.g.dart';

@JsonSerializable()
class ResponseRecipeSearchListApi {
  final int total;
  final List<RecipeSearchItem>? rows;

  ResponseRecipeSearchListApi(this.total, this.rows);

  factory ResponseRecipeSearchListApi.fromJson(Map<String, dynamic> json) =>
      _$ResponseRecipeSearchListApiFromJson(json);

  Map<String, dynamic> toJson() => _$ResponseRecipeSearchListApiToJson(this);
}

@JsonSerializable()
class RecipeSearchItem {
  final String id;
  final String? mainImg;
  final String? imageUrls;
  final String name;
  final int? isControl;
  final int? cookTime;
  final String? cookTimeUnit;
  final String? easyLevelDesc;
  final String? view;
  final String? collection;
  final String? likes;
  final String? videoCoverUrls;

  // 构造函数
  RecipeSearchItem({
    required this.id,
    required this.mainImg,
    required this.imageUrls,
    required this.name,
    required this.isControl,
    required this.cookTime,
    required this.cookTimeUnit,
    required this.easyLevelDesc,
    required this.collection,
    required this.view,
    required this.likes,
    required this.videoCoverUrls,
  });

  // 生成 fromJson 和 toJson 方法
  factory RecipeSearchItem.fromJson(Map<String, dynamic> json) =>
      _$RecipeSearchItemFromJson(json);
  Map<String, dynamic> toJson() => _$RecipeSearchItemToJson(this);
}
